package com.lagou.demo.controller;

import com.lagou.demo.pojo.Articel;
import com.lagou.demo.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author dcwu5
 * @date 2020-06-27
 * @description
 */
@Controller
public class IndexController {

    @Autowired
    private ArticleService articleService;

    @RequestMapping("/index")
    public String index(Model model, @RequestParam(value = "pageNum", defaultValue = "0") int pageNum, @RequestParam(value = "pageSize", defaultValue = "2") int pageSize) {
        Page<Articel> page = articleService.getArticle(pageNum, pageSize);
        model.addAttribute("page", page);
        return "client/index";
    }


}
